import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-05
 * Time: 13:10
 */
public class Test29 {

    public static class ListNode {
        int val;
        ListNode next;

        ListNode(int val) {
            this.val = val;
            next = null;
        }

        ListNode() {

        }
    }

    public static ListNode removeNthFromEnd(ListNode head, int n) {
        ListNode newHead = new ListNode();
        newHead.next = head;
        ListNode fast = newHead;
        ListNode slow = newHead;

        while(n > 0 && fast != null) {
            fast = fast.next;
            n--;
        }
        fast = fast.next;
        while(fast != null) {
            slow = slow.next;
            fast = fast.next;
        }
        slow.next = slow.next.next;
        return newHead.next;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ListNode head = null, tail = null;
        int n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            int val = sc.nextInt();
            ListNode node = new ListNode(val);
            if(head == null) {
                head = node;
            } else {
                tail.next = node;
            }
            tail = node;
        }
        int pos = sc.nextInt();
        ListNode ret = removeNthFromEnd(head,pos);
        while(ret != null) {
            System.out.print(ret.val + " ");
            ret = ret.next;
        }
    }
}
